package com.pro.controller;

import com.pro.pojo.*;
import com.pro.service.JsOrderService;
import com.querydsl.core.types.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cyj
 * @date 2022.1.14$ 15.40$
 * @content :
 */
@RestController
@RequestMapping("/order")
public class JsOrderController {
    @Autowired
    private JsOrderService service;
    /**
     * @author cyj
     * @date 2022.1.14$ 15.40$
     * @content :获取课程订单
     */
    @RequestMapping("/getAllCourseOrder")
    public JsonData getAllCourseOrder(String orderPaymentChannel, String orderSource, String orderStatus,Integer type,Integer comment){
        List<JsOrder> courseOrder=service.getAllCourseOrder(orderPaymentChannel,orderSource,orderStatus,type,comment);
        return courseOrder!=null?JsonData.buildSuccess(courseOrder):JsonData.buildError("服务器错误");
    }

    /**
     * @author cyj
     * @date 2022.1.14$ 19.28$
     * @content :删除订单（商品，课程通用），包括退订
     */
    @RequestMapping("/delCourseOrder")
    public JsonData delCourseOrder(Integer id){
        Boolean flag=service.delCourseOrder(id);
        return flag!=false?JsonData.buildSuccess(flag):JsonData.buildError("服务器错误");
    }

    /**
     * @author cyj
     * @date 2022.1.14$ 19.44$
     * @content :获取一条用户详细信息
     */
    @RequestMapping("/getUserMsg")
    public JsonData getUserMsg(Integer orderId) {
        JsBeforeUser order=service.getUserMsg(orderId);
        return order!=null?JsonData.buildSuccess(order):JsonData.buildError("服务器错误");
    }
    /**
     * @author cyj
     * @date 2022.1.15$ 9.45$
     * @content :获取商品订单
     */
    @RequestMapping("/getAllGoodsOrder")
    public JsonData getAllGoodsOrder(String orderPaymentChannel, String Source, String Status, Integer type,Integer comment) {
        List<JsOrder> jsOrders=service.getAllGoodsOrder(orderPaymentChannel,Source,Status,type,comment);
        return jsOrders!=null?JsonData.buildSuccess(jsOrders):JsonData.buildError("服务器错误");
    }
    /**
     * @author cyj
     * @date 2022.1.15$ 12.02$
     * @content :获取退订订单
     */
    @RequestMapping("/getAllReturnMsg")
    public JsonData getAllReturnMsg(String orderPaymentChannel, String orderSource,Integer Status){
        System.err.println(Status);
        List<Order> retOrders=service.getAllReturnMsg(orderPaymentChannel,orderSource,Status);
        return retOrders!=null?JsonData.buildSuccess(retOrders):JsonData.buildError("服务器错误");
    }
    /**
     * @author cyj
     * @date 2022.1.18$ 17.51$
     * @content :查看商品订单统计
     */
    @RequestMapping("/selectGoodsStatistics")
    public JsonData selectGoodsStatistics(Integer orderType){
        List<JsGoods> retOrders=service.selectGoodsStatistics(orderType);
        return retOrders!=null?JsonData.buildSuccess(retOrders):JsonData.buildError("服务器错误");
    }
    /**
     * @author cyj
     * @date 2022.1.18$ 18.49$
     * @content :查看echarts课程订单统计
     */
    @RequestMapping("/selectCurriculumStatistics")
    public JsonData selectCurriculumStatistics(Integer orderType){
        List<JsCourse> retOrders=service.selectCurriculumStatistics(orderType);
        return retOrders!=null?JsonData.buildSuccess(retOrders):JsonData.buildError("服务器错误");
    }

}
